<script>
xe.lang.msg_empty_search_target = '{$lang->msg_empty_search_target}';
xe.lang.msg_empty_search_keyword = '{$lang->msg_empty_search_keyword}';
xe.lang.msg_select_poll = '{$lang->msg_poll_is_null}';
xe.lang.confirm_poll_delete = '{$lang->confirm_poll_delete}';
</script>
<load target="js/poll_admin.js" usecdn="true" />
<div class="x_page-header">
	<h1>{$lang->poll} <a class="x_icon-question-sign" href="./admin/help/index.html#UMAN_content_poll" target="_blank">{$lang->help}</a></h1>
</div>
<div cond="$XE_VALIDATOR_MESSAGE && $XE_VALIDATOR_ID == 'modules/poll/tpl/poll_list/1'" class="message {$XE_VALIDATOR_MESSAGE_TYPE}">
	<p>{$XE_VALIDATOR_MESSAGE}</p>
</div>
<form ruleset="deleteChecked" action="./" method="post" id="pollList">
	<input type="hidden" name="act" value="procPollAdminDeleteChecked" />
	<input type="hidden" name="page" value="{$page}" />
	<input type="hidden" name="module" value="poll" />
	<input type="hidden" name="xe_validator_id" value="modules/poll/tpl/poll_list/1" />
	<table class="x_table x_table-striped x_table-hover" id="pollListTable">
		<caption>
			<strong>{$lang->all}({number_format($total_count)})</strong>
			<span class="x_pull-right">
				<input type="submit" class="x_btn _allowFreqSubmit" value="{$lang->delete}" />
			</span>
		</caption>
		<thead>
			<tr>
				<th scope="col" class="text">{$lang->title}</th>
				<th scope="col" class="nowr">{$lang->poll_checkcount}</th>
				<th scope="col" class="nowr">{$lang->poll_join_count}</th>
				<th scope="col" class="nowr">{$lang->author}</th>
				<th scope="col" class="nowr">{$lang->regdate}</th>
				<th scope="col" class="nowr">{$lang->poll_stop_date}</th>
				<th scope="col"><input type="checkbox" title="Check All" /></th>
			</tr>
		</thead>
		<tbody>
			<tr loop="$poll_list => $no,$val">
				<td class="title"><a href="<!--@if($val->document_srl)-->{getUrl('')}?document_srl={$val->document_srl}<!--@end--><!--@if($val->comment_srl)-->#comment_{$val->comment_srl}<!--@end-->" target="_blank">{$val->title}</a></td>
				<td class="nowr"><!--@if($val->checkcount == 1)-->{$lang->single_check}<!--@else-->{$lang->multi_check}<!--@end--></td>
				<td class="nowr">{$val->poll_count}</td>
				<td class="nowr"><a href="#popup_menu_area" class="member_{$val->member_srl}">{$val->nick_name}</a></td>
				<td class="nowr">{zdate($val->poll_regdate,"Y-m-d H:i")}</td>
				<td class="nowr">{zdate($val->poll_stop_date,"Y-m-d")}</td>
				<td>
					<input type="checkbox" name="cart[]" value="{$val->poll_index_srl}" />
				</td>
			</tr>
			<tr cond="!$poll_list">
				<td colspan="7" style="text-align:center">{$lang->no_data}</td>
			</tr>
		</tbody>
	</table>
	<span class="x_pull-right">
		<input type="submit" class="x_btn _allowFreqSubmit" value="{$lang->delete}" />
	</span>
</form>

<form action="./" class="x_pagination x_pull-left" style="margin:0" no-error-return-url="true">
	<input type="hidden" name="module" value="{$module}" />
	<input type="hidden" name="act" value="{$act}" />
	<input cond="$search_keyword" type="hidden" name="search_keyword" value="{$search_keyword}" />
	<input cond="$search_target" type="hidden" name="search_target" value="{$search_target}" />
	<ul>
		<li class="x_disabled"|cond="!$page || $page == 1"><a href="{getUrl('page', '')}">&laquo; {$lang->first_page}</a></li>
		<block cond="$page_navigation->first_page != 1 && $page_navigation->first_page + $page_navigation->page_count > $page_navigation->last_page - 1 && $page_navigation->page_count != $page_navigation->total_page">
		{@$isGoTo = true}
		<li>
			<a href="#goTo" data-toggle title="{$lang->cmd_go_to_page}">&hellip;</a>
			<span cond="$isGoTo" id="goTo" class="x_input-append">
				<input type="number" min="1" max="{$page_navigation->last_page}" required name="page" title="{$lang->cmd_go_to_page}" />
				<button type="submit" class="x_add-on">Go</button>
			</span>
		</li>
		</block>

		<!--@while($page_no = $page_navigation->getNextPage())-->
		{@$last_page = $page_no}
		<li class="x_active"|cond="$page_no == $page"><a  href="{getUrl('page', $page_no)}">{$page_no}</a></li>
		<!--@end-->

		<block cond="$last_page != $page_navigation->last_page && $last_page + 1 != $page_navigation->last_page">
		{@$isGoTo = true}
		<li>
			<a href="#goTo" data-toggle title="{$lang->cmd_go_to_page}">&hellip;</a>
			<span cond="$isGoTo" id="goTo" class="x_input-append">
				<input type="number" min="1" max="{$page_navigation->last_page}" required name="page" title="{$lang->cmd_go_to_page}" />
				<button type="submit" class="x_add-on">Go</button>
			</span>
		</li>
		</block>
		<li class="x_disabled"|cond="$page == $page_navigation->last_page"><a href="{getUrl('page', $page_navigation->last_page)}" title="{$page_navigation->last_page}">{$lang->last_page} &raquo;</a></li>
	</ul>
</form>

<form action="./" method="get" class="search center x_input-append" style="clear:both;padding:10px 0 0 0;margin:0" no-error-return-url="true">
	<input type="hidden" name="module" value="{$module}" />
	<input type="hidden" name="act" value="{$act}" />
	<select name="search_target" title="{$lang->search_target}" style="margin-right:4px">
		<option loop="$lang->search_poll_target_list => $key, $val" value="{$key}" selected="selected"|cond="$search_target==$key">{$val}</option>
	</select>
	<input type="search" name="search_keyword" value="{htmlspecialchars($search_keyword)}" />
	<button class="x_btn x_btn-inverse" type="submit">{$lang->cmd_search}</button>
	<a class="x_btn" href="{getUrl('','module',$module,'act',$act)}">{$lang->cmd_cancel}</a>
</form>
<script>
jQuery(function($){
	// Modal anchor activation
	var $docTable = $('#pollListTable');
	var $submit = $('#pollList [type="submit"]');
	$docTable.find(':checkbox').change(function(){
		if($docTable.find('tbody :checked').length == 0){
			$submit.addClass('x_disabled');
		} else {
			$submit.removeClass('x_disabled');
		}
	}).change();
	// Button action
	$submit.click(function(){
		if($docTable.find('tbody :checked').length == 0){
			alert(xe.lang.msg_select_poll);
			return false;
		}
	});
});
</script>